# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-coapthon
pkgname=('python2-coapthon' 'python-coapthon')
_pkgname=CoAPthon
pkgver=4.0.2
pkgrel=7
pkgdesc='An implementation of the CoAP protocol.'
arch=('any')
url='https://pypi.org/project/coapthon/#files'
license=('MIT')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('79a668680f9eba30d6924294be115610210383192e2f079121bebd43331b07b7cdbc482add57a9286dacb1164687a6801b0d2eedd50fff71ccc0b459a90e8f1e')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-coapthon() {
  depends=('python2' 'python2-cachetools' 'python2-sphinx')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

package_python-coapthon() {
  depends=('python' 'python-cachetools' 'python-sphinx')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

